#include <osgViewer/Viewer>
#include <osgViewer/GraphicsWindow>
#include <osg/Node>
#include <osg/Geode>
#include <osg/Image>
#include <osg/Camera>
#include <osg/BufferObject>
#include <osgText/Text>
#include <osg/ValueObject>

#include <osgDB/ReadFile>
#include <osgDB/WriteFile>
#include <osgUtil/Optimizer>
#include <osgGA/GUIEventAdapter>
#include <osgGA/GUIEventHandler>
#include <osgGA/GUIActionAdapter>

namespace Osgis{
	class CaptureScreenCallback : public osg::Camera::DrawCallback
	{
	public:
		CaptureScreenCallback(osg::Image* image, osgText::Text* text):_image(image), _text(text)
		{

		}
		virtual void operator() (osg::RenderInfo& renderInfo) const;
	protected:
		osg::ref_ptr<osg::Image> _image;
		osg::observer_ptr<osgText::Text> _text;
		mutable int _fileIndex;
	};

	class ImageHandler :public osgGA::GUIEventHandler
	{
	public:
		ImageHandler(osg::Image* img):_image(img)
		{

		}
	public:
		bool ImageHandler::handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa)
		{
			if(_image.valid() && ea.getEventType() == osgGA::GUIEventAdapter::KEYDOWN &&ea.getKey() == 'p')
				_image->setUserValue("Capture", true);
			return false;
		}
	protected:
		osg::ref_ptr<osg::Image> _image;

	};
}